Public Class ctlEventLogViewer
    Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'UserControl overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents tvwEvents As System.Windows.Forms.TreeView
    Friend WithEvents pnlTextPanel As System.Windows.Forms.Panel
    Friend WithEvents lblText As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.tvwEvents = New System.Windows.Forms.TreeView()
        Me.pnlTextPanel = New System.Windows.Forms.Panel()
        Me.lblText = New System.Windows.Forms.Label()
        Me.pnlTextPanel.SuspendLayout()
        Me.SuspendLayout()
        '
        'tvwEvents
        '
        Me.tvwEvents.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right)
        Me.tvwEvents.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tvwEvents.ImageIndex = -1
        Me.tvwEvents.Location = New System.Drawing.Point(8, 40)
        Me.tvwEvents.Name = "tvwEvents"
        Me.tvwEvents.SelectedImageIndex = -1
        Me.tvwEvents.ShowRootLines = False
        Me.tvwEvents.Size = New System.Drawing.Size(472, 72)
        Me.tvwEvents.TabIndex = 4
        '
        'pnlTextPanel
        '
        Me.pnlTextPanel.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right)
        Me.pnlTextPanel.BackColor = System.Drawing.Color.SteelBlue
        Me.pnlTextPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlTextPanel.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblText})
        Me.pnlTextPanel.Name = "pnlTextPanel"
        Me.pnlTextPanel.Size = New System.Drawing.Size(488, 32)
        Me.pnlTextPanel.TabIndex = 3
        '
        'lblText
        '
        Me.lblText.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblText.Location = New System.Drawing.Point(8, 5)
        Me.lblText.Name = "lblText"
        Me.lblText.Size = New System.Drawing.Size(152, 24)
        Me.lblText.TabIndex = 0
        Me.lblText.Text = "Events"
        '
        'ctlEventLogViewer
        '
        Me.BackColor = System.Drawing.Color.LightSkyBlue
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.tvwEvents, Me.pnlTextPanel})
        Me.Name = "ctlEventLogViewer"
        Me.Size = New System.Drawing.Size(488, 120)
        Me.pnlTextPanel.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public Sub ClearList()
        Try
            tvwEvents.Nodes.Clear()
        Catch

        End Try
    End Sub

    Public Sub ListEvents(ByRef gameData As cmplib01.CampaignerGameData)
        ClearList()
        Dim key As String
        Dim Levent As cmplib01.LogEvent

        For Each key In gameData.LogEvents.Keys
            Dim titleNode As New TreeNode()
            Dim bAddEvent As Boolean

            Levent = gameData.LogEvents.Item(key)
            ' being a treeview, we can continue to drill information down if we choose
            Select Case Levent.AuthorityLevel
                Case cmplib01.EventAuthorityLevel.PublicEvent
                    bAddEvent = True
                Case cmplib01.EventAuthorityLevel.FriendlyEvent
                Case cmplib01.EventAuthorityLevel.OwningEvent
                Case cmplib01.EventAuthorityLevel.ModeratorEvent
                    If gameData.selectedPlayer.PlayerName = "<Moderator>" Then
                        ' add the moderator event
                        bAddEvent = True
                    End If
            End Select
            If bAddEvent Then
                titleNode.Text = "{Turn: " & Levent.TurnNumber & "} " & Levent.Action & " [" & Levent.InvokingPlayerName & "]"
                tvwEvents.Nodes.Add(titleNode)
            End If
        Next
    End Sub

End Class
